package com.xu.factory;

/**
 * 返利收费子类
 * @author xudenghui
 * @create 2023-05-15 10:41
 **/
public class CashReturn implements  CashSuper{

    private double moneyCondition = 0.0d;
    private double moneyReturn = 0.0d;

    /**
     * 返利收费，初始化时必须要输入返利条件 和返回值，比如满300 返 100 则 moneyCondition 300  moneyReturn 为100
     * @param moneyCondition
     * @param moneyReturn
     */
    public CashReturn(String moneyCondition, String moneyReturn) {
        this.moneyCondition = Double.valueOf(moneyCondition);
        this.moneyReturn = Double.valueOf(moneyReturn);
    }

    public double acceptCash(double money) {
        double result = money;
        if (money >= moneyCondition){
            result = money - (money/moneyCondition)*moneyReturn;
        }
        return result;
    }
}
